package com.ruoyi.web.controller.cinema;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cinema.domain.ComboGroupInfo;
import com.ruoyi.cinema.service.IComboGroupInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 套餐组合Controller
 *
 * @author HHAOYU
 * @date 2020-12-09
 */
@RestController
@RequestMapping("/cinema/comboGroupInfo")
public class ComboGroupInfoController extends BaseController
{
    @Autowired
    private IComboGroupInfoService comboGroupInfoService;

    /**
     * 查询套餐组合列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:comboGroupInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ComboGroupInfo comboGroupInfo)
    {
        startPage();
        List<ComboGroupInfo> list = comboGroupInfoService.selectComboGroupInfoList(comboGroupInfo);
        return getDataTable(list);
    }

    /**
     * 导出套餐组合列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:comboGroupInfo:export')")
    @Log(title = "套餐组合", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ComboGroupInfo comboGroupInfo)
    {
        List<ComboGroupInfo> list = comboGroupInfoService.selectComboGroupInfoList(comboGroupInfo);
        ExcelUtil<ComboGroupInfo> util = new ExcelUtil<ComboGroupInfo>(ComboGroupInfo.class);
        return util.exportExcel(list, "comboGroupInfo");
    }

    /**
     * 获取套餐组合详细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:comboGroupInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(comboGroupInfoService.selectComboGroupInfoById(id));
    }

    /**
     * 新增套餐组合
     */
    @PreAuthorize("@ss.hasPermi('cinema:comboGroupInfo:add')")
    @Log(title = "套餐组合", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ComboGroupInfo comboGroupInfo)
    {
        return toAjax(comboGroupInfoService.insertComboGroupInfo(comboGroupInfo));
    }

    /**
     * 修改套餐组合
     */
    @PreAuthorize("@ss.hasPermi('cinema:comboGroupInfo:edit')")
    @Log(title = "套餐组合", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ComboGroupInfo comboGroupInfo)
    {
        return toAjax(comboGroupInfoService.updateComboGroupInfo(comboGroupInfo));
    }

    /**
     * 删除套餐组合
     */
    @PreAuthorize("@ss.hasPermi('cinema:comboGroupInfo:remove')")
    @Log(title = "套餐组合", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(comboGroupInfoService.deleteComboGroupInfoByIds(ids));
    }
}
